package Leetcode;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class removeNthFromEnd {
    public int count = 0;
    public ListNode removeNthFromEnd(ListNode head, int n) {
        return findNode(head, n);
    }
    public ListNode findNode(ListNode node, int n){
        if (node == null){
            return null;
        }
        node.next = findNode(node.next, n);
        count++;
        if (count == n){
            return node.next;
        }
        return node;
    }
}
